From f16bd54da6d2334fd6d36b0e2c2729e1cf1bdc05 Mon Sep 17 00:00:00 2001
From: Jussi Pakkanen <jpakkane@gmail.com>
Date: Mon, 17 Jun 2019 21:49:34 +0300
Subject: [PATCH] Handle thread flags when not using C at all. Closes #5497.

---
 mesonbuild/dependencies/misc.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index af2da29b63..e5fab64599 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -388,8 +388,14 @@ def __init__(self, environment, kwargs):
         super().__init__('threads', environment, None, kwargs)
         self.name = 'threads'
         self.is_found = True
-        self.compile_args = self.clib_compiler.thread_flags(environment)
-        self.link_args = self.clib_compiler.thread_link_flags(environment)
+        # Happens if you are using a language with threads
+        # concept without C, such as plain Cuda.
+        if self.clib_compiler is None:
+            self.compile_args = []
+            self.link_args = []
+        else:
+            self.compile_args = self.clib_compiler.thread_flags(environment)
+            self.link_args = self.clib_compiler.thread_link_flags(environment)
 
 
 class Python3Dependency(ExternalDependency):
